package com.wyzz.hr.pojo.base;

import com.wyzz.hr.base.BaseDomain;
import com.wyzz.hr.bo.IEmployeeBo;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Empsalarypay;
import com.wyzz.hr.pojo.Location;
import com.wyzz.hr.spring.SpringBeanFactory;

import java.io.Serializable;
import java.util.*;

public abstract class BaseLocation extends BaseDomain implements Serializable {

	public BaseLocation() {
		hashCode = 0x80000000;
		initialize();
	}

	public BaseLocation(String id) {
		hashCode = 0x80000000;
		setId(id);
		initialize();
	}

	public BaseLocation(String id, String locationName, Integer locationSortId) {
		hashCode = 0x80000000;
		setId(id);
		setLocationName(locationName);
		setLocationSortId(locationSortId);
		initialize();
	}

	protected void initialize() {
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
		hashCode = 0x80000000;
	}

	public String getLocationName() {
		return locationName;
	}

	public void setLocationName(String locationName) {
		this.locationName = locationName;
	}

	public String getLocationDesc() {
		return locationDesc;
	}

	public void setLocationDesc(String locationDesc) {
		this.locationDesc = locationDesc;
	}

	public Integer getLocationSortId() {
		return locationSortId;
	}

	public void setLocationSortId(Integer locationSortId) {
		this.locationSortId = locationSortId;
	}

	public Set getEmpsalarypaids() {
		return empsalarypaids;
	}

	public void setEmpsalarypaids(Set empsalarypaids) {
		this.empsalarypaids = empsalarypaids;
	}

	public void addToempsalarypaids(Empsalarypay empsalarypaid) {
		if (null == getEmpsalarypaids())
			setEmpsalarypaids(new TreeSet());
		getEmpsalarypaids().add(empsalarypaid);
	}

	public Set getEmployees() {
		return employees;
	}

	public void setEmployees(Set employees) {
		this.employees = employees;
	}

	public void addToemployees(Employee employee) {
		if (null == getEmployees())
			setEmployees(new TreeSet());
		getEmployees().add(employee);
	}

	public boolean equals(Object obj) {
		if (null == obj)
			return false;
		if (!(obj instanceof Location))
			return false;
		Location location = (Location) obj;
		if (null == getId() || null == location.getId())
			return false;
		else
			return getId().equals(location.getId());
	}

	public int hashCode() {
		if (0x80000000 == hashCode) {
			if (null == getId())
				return super.hashCode();
			String hashStr = (new StringBuilder()).append(getClass().getName())
					.append(":").append(getId().hashCode()).toString();
			hashCode = hashStr.hashCode();
		}
		return hashCode;
	}

	public String toString() {
		return super.toString();
	}

	public String getHeadNo() {
		if (headNo != null)
			return headNo;
		if (getId() == null)
			return null;
		IEmployeeBo empBo = (IEmployeeBo) SpringBeanFactory.getBean("empBo");
		String hql = (new StringBuilder()).append(
				"SELECT orgheadsEmpNo from Orgheads where orgheadsOrgNo ='")
				.append(getId()).append(
						"' and orgheadsResponsibility='locheader'").toString();
		List list = empBo.exeHqlList(hql, new int[0]);
		if (list == null || list.size() == 0)
			return null;
		else
			return (String) list.get(0);
	}

	public void setHeadNo(String headNo) {
		this.headNo = headNo;
	}

	public Integer getLocationStatus() {
		return locationStatus;
	}

	public void setLocationStatus(Integer locationStatus) {
		this.locationStatus = locationStatus;
	}

	public static String REF = "Location";
	public static String PROP_LOCATION_DESC = "locationDesc";
	public static String PROP_LOCATION_SORT_ID = "locationSortId";
	public static String PROP_LOCATION_NAME = "locationName";
	public static String PROP_ID = "id";
	public static String PROP_LOCATION_STATUS = "locationStatus";
	private int hashCode;
	private String id;
	private String locationName;
	private String locationDesc;
	private Integer locationSortId;
	private Integer locationStatus;
	public String headNo;
	private Set empsalarypaids;
	private Set employees;

}
